package model;

import java.util.ArrayList;

import view.IView;

public class Perspective implements IModel {
	
	private ArrayList<IView> views;
	private Translation translation = new Translation();
	private Zoom zoom = new Zoom();
	
	public Perspective() {
		views = new ArrayList<IView>();
		translation = new Translation();
		zoom = new Zoom();
	}
	
	@Override
	public void registerObserver(IView view) {
		views.add(view);
	}
	
	@Override
	public void removeObserver(IView view) {
		views.remove(view);
	}
	
	@Override
	public void notifyObservers() {
		for(IView i : views) {
			i.update();
		}
	}

	public void setTranslation(int xPosition, int yPosition) {
		translation.setxPosition(xPosition);
		translation.setyPosition(yPosition);
		notifyObservers();
	}
	
	public void setxPosition(int xPosition) {
		translation.setxPosition(xPosition);
		notifyObservers();
	}
	
	public void updatexPosition(int xTranslation) {
		translation.updatexPosition(xTranslation);
		notifyObservers();
	}
	
	public int getxPosition() {
		return translation.getxPosition();
	}
	
	public void setyPosition(int yPosition) {
		translation.setyPosition(yPosition);
		notifyObservers();
	}
	
	public void updateyPosition(int yTranslation) {
		translation.updateyPosition(yTranslation);
		notifyObservers();
	}
	
	public int getyPosition() {
		return translation.getyPosition();
	}
	
	public Translation getTranslation() {
		return translation;
	}
	
	public void updateZoomPercentage(double zoomPercentage) {
		zoom.updateZoomPercentage(zoomPercentage);
	}
	
	public void setZoom(double zoomPercentage) {
		zoom.setZoomPercentage(zoomPercentage);
		notifyObservers();
	}
	
	public double getZoomPercentage() {
		return zoom.getZoomPercentage();
	}
	
	public Zoom getZoom() {
		return zoom;
	}
	
	public void reset() {
		translation.reset();
		zoom.reset();
	}
}